package com.yue.jersey;

import com.yue.jersey.practice.PracticeResourceConfig;
import com.yue.jersey.public_jersey.PublicJerseyResourceConfig;
import com.yue.jersey.private_jersey.PrivateJerseyResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/11/23<br/>
 *
 * @author QiuYang
 */
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = {
        "com.yue.jersey.private_jersey",
        "com.yue.jersey.public_jersey",
        "com.yue.jersey.practice"
})
public class ServletResourceConfig {

    @Bean
    public ServletRegistrationBean getPublicJerseyResourceConfig(){
        ServletRegistrationBean publicJerseyResourceConfig = new ServletRegistrationBean(
                new ServletContainer(new PublicJerseyResourceConfig()), "/public/*");
        publicJerseyResourceConfig.setLoadOnStartup(0);
        publicJerseyResourceConfig.setName("publicJerseyResourceCofig_Servlet");
        return publicJerseyResourceConfig;
    }

    @Bean
    public ServletRegistrationBean getPrivateJerseyResourceConfig(){
        ServletRegistrationBean privateJerseyResourceConfig = new ServletRegistrationBean(
                new ServletContainer(new PrivateJerseyResourceConfig()), "/private/*");
        privateJerseyResourceConfig.setLoadOnStartup(1);
        privateJerseyResourceConfig.setName("privateJerseyResourceConfig_Servlet");
        return privateJerseyResourceConfig;
    }

    @Bean
    public ServletRegistrationBean getPracticeResourceConfig(){
        ServletRegistrationBean practiceResourceConfig = new ServletRegistrationBean(
                new ServletContainer(new PracticeResourceConfig()), "/practice/*");
        practiceResourceConfig.setLoadOnStartup(2);
        practiceResourceConfig.setName("practiceResourceConfig_Servlet");
        return practiceResourceConfig;
    }
}
